package com.gxa.order.controller;

import com.gxa.order.dto.PageParam;
import com.gxa.order.param.LikeParam;
import com.gxa.order.param.PastLikeParam;
import com.gxa.order.service.ArtOrderService;
import com.gxa.order.service.MacOrderService;
import com.gxa.order.service.OrderManageService;
import com.gxa.order.service.PastTicketService;
import dto.ResultDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.springframework.web.bind.annotation.*;
import util.Response;

import javax.annotation.Resource;

@RestController
@RequestMapping("order02")
@Api(tags = "订单模块02")
public class OrderController02 {

    @Resource
    private PastTicketService pastTicketService;

    @Resource
    private OrderManageService orderManageService;

    @Resource
    private MacOrderService macOrderService;

    @Resource
    private ArtOrderService artOrderService;

    /**
     * 查看历史订单
     * @param memberId
     * @return
     */
    @PostMapping("/past/ticket")
    @ApiOperation(value = "查看历史订单")
    public ResultDTO pastTicket(@RequestParam Integer memberId, @RequestBody PastLikeParam likeParam){
        System.out.println("***************************");
        return pastTicketService.findPastTicket(memberId, likeParam);
    }

    /**
     * 取消历史订单
     * @return
     */
    @PostMapping("/past/cancel")
    @ApiOperation(value = "取消历史订单")
    public ResultDTO pastTicket(@RequestParam Integer orderId, @RequestParam Integer type, @RequestParam String msg){
        return pastTicketService.updateStatus(orderId, type, msg);
    }

    @PostMapping("/past/email")
    @ApiOperation(value = "发送email历史订单")
    public ResultDTO pastEmail(@RequestParam Integer orderId, @RequestParam Integer type){
        return pastTicketService.sendEmail(orderId, type);
    }

    /**
     * 订单管理
     * @return
     */
    @PostMapping("/manage/ticket")
    @ApiOperation(value = "查看管理订单")
    public ResultDTO manageTicket(@RequestParam Integer memberId, @RequestBody LikeParam likeParam){
        return orderManageService.findAllOrder(memberId, likeParam);
    }


    /**
     * 人工单通过
     * @param orderId
     * @return
     */
    @PostMapping("/manage/art/pass")
    public ResultDTO manageArtPass(@RequestParam Integer orderId){
        return orderManageService.updateStatusArtPass(orderId);
    }

    /**
     * 人工单拒绝
     * @param orderId
     * @return
     */
    @PostMapping("/manage/art/cancel")
    public ResultDTO manageArtCancel(@RequestParam Integer orderId){
        return orderManageService.updateStatusArtCancel(orderId);
    }

    /**
     * 机械单通过
     * @param orderId
     * @return
     */
    @PostMapping("/manage/mac/pass")
    public ResultDTO manageMacPass(@RequestParam Integer orderId){
        return orderManageService.updateStatusMacPass(orderId);
    }

    /**
     * 机械单拒绝
     * @param orderId
     * @return
     */
    @PostMapping("/manage/mac/cancel")
    public ResultDTO manageMacCancel(@RequestParam Integer orderId){
        return orderManageService.updateStatusMacCancel(orderId);
    }

    /**
     * 查询机械订单
     * @param macOrderId
     * @return
     */
    @PostMapping("find/by/macOrderId")
    public ResultDTO findByMacOrderId(@RequestParam Integer macOrderId){
        return macOrderService.queryById(macOrderId);
    }

    /**
     * 查询人工订单
     * @param artOrderId
     * @return
     */
    @PostMapping("find/by/artOrderId")
    public ResultDTO findByArtOrderId(@RequestParam Integer artOrderId){
        return artOrderService.queryById(artOrderId);
    }

    /**
     * 机械单待审核中
     * @param orderId
     * @return
     */
    @PostMapping("/manage/mac/in")
    public ResultDTO manageMacIn(@RequestParam Integer orderId){
        return orderManageService.updateStatusMacIn(orderId);
    }

    /**
     * 机票地址
     * @return
     */
    @PostMapping("find/past/airport")
    @ApiOperation(value = "查看机场地址")
    public ResultDTO findAirport(){
        return pastTicketService.findA();
    }
}
